package com.back.controller;

import com.back.model.dto.GroupcDTO;
import com.back.model.entity.Groupc;
import com.back.model.entity.User;
import com.back.model.reslut.Result;
import com.back.service.GroupcService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/gpoup")
public class GoupcController {

    @Resource
    private GroupcService groupcService;

    @PostMapping("/create")
    public Result createGroup(@RequestBody GroupcDTO groupcDTO) {
        Groupc groupc = groupcService.createGroup(groupcDTO);
        return Result.successData(groupc);
    }

    @PostMapping("/join")
    public Result joinGroup(GroupcDTO groupcDTO) {
        Groupc groupc = groupcService.joinGroup(groupcDTO);
        return Result.successData(groupc);
    }
    @PostMapping("/exit")
    public Result exitGroup(GroupcDTO groupcDTO) {
        int groupc = groupcService.exitGroup(groupcDTO);
        return Result.successData(groupc);
    }
    @PostMapping("/getGroupUse")
    public Result getGroupUser(GroupcDTO groupcDTO) {
        List<User> list = groupcService.getGroupUser(groupcDTO);
        return Result.successData(list);
    }

}
